#include "debugging.h"

namespace Softwarer {
    Debugging::Debugging() 
        : m_logLevel(INFO)
        , m_logger(nullptr)
        , m_display(new ConsoleDisplay())
    {}

    Logger* Debugging::createLogger()
    {
        if (m_logger == nullptr) {
            m_logger = new Logger(m_logLevel, m_display);
        }
        return m_logger;
    }

    void Debugging::setDisplay(IDisplay* display)
    {
        if (m_logger != nullptr)
        {
            m_logger->m_display = display;
        }
        delete m_display;
        m_display = display;
    }

    Debugging* Softwarer::Debugging::createDebugging()
    {
        static Debugging debugging;
        return &debugging;
    }
    Debugging::~Debugging()
    {
        delete m_logger;
        delete m_display;
    }
    Logger* createLogger()
    {
        return Debugging::createDebugging()->createLogger();
    }
}